efform_onload = function ()
{
};

button_query_onclick = function (){
	efgrid.submitInqu( "ef_grid_result", "ZM", "ZMCG84", "query");
}

button_update_onclick = function (){
	var grid=isSelected("ef_grid_result");
	if (grid == 0)return; 
	var rows=grid.getCheckedRows();
	for(var i=0;i<rows.length;i++)
	{
		if(grid.getCellValueByColumnName(rows[i],"fdStatus")!="草拟")
		{
			EFAlert("只能对草拟的记录进行修改！"); return;
		}
	}
	efgrid.submitForm( "ef_grid_result", "ZM", "ZMCG84", "update", true);
}

button_insert_onclick = function (){
	var grid=isSelected("ef_grid_result");
	if (grid == 0)return; 
	var rows=grid.getCheckedRows();
	for(var i=0;i<rows.length;i++)
	{
		if(grid.getCellValueByColumnName(rows[i],"fdStatus")!="草拟")
		{
			EFAlert("只能对草拟的记录进行新增！"); return;
		}
	}
	efgrid.submitForm( "ef_grid_result", "ZM", "ZMCG84", "insert", true);
}

button_delete_onclick = function (){
	var grid=isSelected("ef_grid_result");
	if (grid == 0)return; 
	var rows=grid.getCheckedRows();
	for(var i=0;i<rows.length;i++)
	{
		if(grid.getCellValueByColumnName(rows[i],"fdStatus")!="草拟")
		{
			EFAlert("只能对草拟的记录进行删除！"); return;
		}
	}
	EFConfirm('你确认要删除吗?', '确认框', function(r) {
		if(r)efgrid.submitForm( "ef_grid_result", "ZM", "ZMCG84", "delete", true);
	});
}

button_report_onclick = function (){
	var grid=isSelected("ef_grid_result");
	if (grid == 0)  return;
	var rows=grid.getCheckedRows();
	for(var i=0;i<rows.length;i++)
	{
		if(grid.getCellValueByColumnName(rows[i],"fdStatus")!="草拟")
		{
			EFAlert("只能对草拟的记录进行上报！"); return;
		}
	}
	EFConfirm('确认要上报吗?', '确认框', function(r) {
		if(r)efgrid.submitForm( "ef_grid_result", "ZM", "ZMCG84", "report", true);
	});
}

button_goback_onclick = function (){
	var grid=isSelected("ef_grid_result");
	if (grid == 0)return; 
	var rows=grid.getCheckedRows();
	for(var i=0;i<rows.length;i++)
	{
		if(grid.getCellValueByColumnName(rows[i],"fdStatus")=="上报")
		{
			EFAlert("只能对草拟的记录进行退回！"); return;
		}
	}
	EFConfirm('确认要退回吗?', '确认框', function(r) {
		if(r)efgrid.submitForm( "ef_grid_result", "ZM", "ZMCG84", "goback", true);
	});
}

efgrid_afterAddNewRow = function(grid_id) {
	var grid = efgrid.getGridObject(grid_id);
	var rows = grid.getCheckedRows();
	if (grid_id == "ef_grid_result") {
		for (var i = 0; i < rows.length; i++) {
			grid.getBlockData().setCell(rows[i], "fdStatus", "草拟");
			grid.getBlockData().setCell(rows[i], "fdCurrentDate", getCurrentDate());
		}
	}
	for (var i = 0; i < rows.length; i++) {
		grid.getBlockData().setCell(rows[i], "fdKeyId", "");
	}
}
//新增、修改、删除后的执行方法
efgrid_onAjaxSubmitSuccess = function(gridId, service_name, method_name, eiInfo) {
	if(gridId == "ef_grid_result") {
		if (eiInfo.status != -1) {
			var grid = efgrid.getGridObject("ef_grid_result");
			grid.refresh( eiInfo );
			if(method_name = "report")
			{
				parent.refresh_JJgrid();
			}
		}
		else
		{
			submitCallBackEiMsg = eiInfo.msg;
		}
	}
};
